//
//  PeopleDetailsViewController.m
//  QT
//
//  Created by 甘世清 on 2024/10/25.
//

#import "PeopleDetailsViewController.h"
#import "PeopleTopView.h"
#import "PictureTableViewCell.h"
#import "PictureDetailViewController.h"
#import "PeopleModel.h"
#import "ReportPopView.h"
#import "AboutTableViewCell.h"
@interface PeopleDetailsViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic , strong) PeopleTopView * topView;
@property (nonatomic , strong) PeopleModel * model;
@end

@implementation PeopleDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    WS(weakSelf);
    [self zx_setRightBtnWithImg:SQGetImage(@"gengduo") clickedBlock:^(ZXNavItemBtn * _Nonnull btn) {
        [weakSelf SQ_reportPopViewClick];
    }];
}

- (void)SQ_UIViewForSelfView{
    self.tableView.tableHeaderView = self.topView;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    WS(weakSelf);
    self.topView.model = [PeopleModel new];
    self.model = [PeopleModel new];
    self.model.remark = @"一阿打算打代码大梅沙大萨达啊啊啊啊啊啊啊一阿打算打代码大梅沙大萨达啊啊啊啊啊啊啊一阿打算打代码大梅沙大萨达啊啊啊啊啊啊啊一阿打算打代码大梅沙大萨达啊啊啊啊啊啊啊一阿打算打代码大梅沙大萨达啊啊啊啊啊啊啊一阿打算打代码大梅沙大萨达啊啊啊啊啊啊啊一阿打算打代码大梅沙大萨达啊啊啊啊啊啊啊一阿打算打代码大梅沙大萨达啊啊啊啊啊啊啊一阿打算打代码大梅沙大萨达啊啊啊啊啊啊啊一阿打算打代码大梅沙大萨达啊啊啊啊啊啊啊";
    [self.tableView reloadData];
  
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    if ([self.model.remark isNotEmpty]) {
        return 2;
    }
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        if ([self.model.remark isNotEmpty]) {
            return 1;
        }
    }
   return self.jsonArray.count +10;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        if ([self.model.remark isNotEmpty]) {
            AboutTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AboutTableViewCell"];
            if (!cell) {
                cell = [[AboutTableViewCell alloc] initWithStyle:(UITableViewCellStyleValue1) reuseIdentifier:@"AboutTableViewCell"];
            }
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.aboutLabel.text = self.model.remark;
            return cell;
        }
    }
    PictureTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PictureTableViewCell"];
    if (!cell) {
        cell = [[PictureTableViewCell alloc] initWithStyle:(UITableViewCellStyleValue1) reuseIdentifier:@"PictureTableViewCell"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.model = [PictureModel new];// [self.jsonArray  objectAtIndex:indexPath.item];
    
    return cell;
}
 

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        if ([self.model.remark isNotEmpty]) {
            return [AboutTableViewCell FSCellHeightForTableView:tableView indexPath:indexPath cellContentViewWidth:0 bottomOffset:10];
        }
    }
    return 240;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    PictureDetailViewController * vc = [[PictureDetailViewController alloc]init];
    [self SQ_pushViewControllerFull:vc];
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
   
    UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDETH, 10)];
    view.backgroundColor = UIColor.whiteColor;
    UILabel * label  = [[UILabel alloc]init];
    label.text = SQNSLocalString(@"相易列表");
    if (section == 0) {
        if ([self.model.remark isNotEmpty]) {
            label.text = SQNSLocalString(@"个人简介");
        }
    }
    label.font = FONT_MEDIUM(16);
    label.textColor = SQColor333333;
    [view addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(view).offset(5);
            make.left.equalTo(view).offset(12);
    }];
    return view;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 40;
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    CGFloat offSetH = scrollView.contentOffset.y;
    if (offSetH > 170) {
        self.zx_navBarBackgroundColor = UIColor.whiteColor;
        self.zx_navTitle = @"名字名字";
    } else {
        self.zx_navBarBackgroundColor = UIColor.clearColor;
        self.zx_navTitle = @"";
    }
}
 

-(void)SQ_reportPopViewClick{
    WS(weakSelf);
    ReportPopView * vc = [[ReportPopView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDETH, 200+FootHeight)];
    LSTPopView * pop = [LSTPopView initWithCustomView:vc
                                           parentView:nil
                                             popStyle:LSTPopStyleSmoothFromBottom dismissStyle:LSTDismissStyleSmoothToBottom];
    pop.hemStyle = LSTHemStyleBottom;
    [pop pop];
    LSTPopViewWK(pop)
    [pop setBgClickBlock:^{
        [wk_pop dismiss];
    }];
}

- (PeopleTopView *)topView{
    if (!_topView) {
        _topView = [[PeopleTopView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDETH, 400)];
    }
    return _topView;
}

@end
